variables
Modern computers have a large amount of main memory (also called RAM). This memory is used for many things. When you run a QBasic program, the statements of the program are stored in main memory. The data for the program also can be stored in main memory.
A variable in QBasic is a small amount of computer memory that has been given a name. You (the programmer) think of the name you want to use. The QBasic system will use a section of main memory for that name.
A variable is like a small box that holds a value. The value in the variable can change (that is why it is called a variable). Here is a program that uses a variable:
' Program that uses a variable ' LET NUM = 23.5 PRINT "The variable contains", NUM END
When this program runs, the value 23.5 is placed in the variable NUM
.
Then the following is written to the monitor:
The variable contains 23.5
What do you think the following program will write to the monitor?
' Program with a variable ' LET NUM = 53 PRINT "The variable contains", NUM END